<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../css/iconfont.css"/>
</head>
<body >
<style type="text/css">
</style>
  <div class="br" >

  </div>
  <div class="open-vip-t">
    <div class="br"></div>
    <div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label-icon">
                        <i class="aui-iconfont aui-icon-lock"></i>
                    </div>
                    <div class="aui-list-item-input">
                        <input id="kami" type="text" placeholder="在此处粘贴卡密">
                    </div>
                </div>
            </li>
        </ul>
    </div>
    <div class="aui-content-padded">
        <p><div class="aui-btn-tuichu aui-btn-block" tapmode onclick="loginOff()">立 即 开 通</div></p>
    </div>
  </div>

  <div class="open-vip-b" >
    <div >
      <div id="imgurl" class="open-vip-b-ka" >
        <img id="imgurl1" src="../image/30.png" tapmode onclick="openUrl1()">
        <img id="imgurl2" src="../image/90.png" tapmode onclick="openUrl2()">
        <img id="imgurl3" src="../image/365.png" tapmode onclick="openUrl3()">
        <img id="imgurl4" src="../image/yongjiu.png" tapmode onclick="openUrl4()">
      </div>
      <p>&nbsp; </p>
      <div class="open-vip-b-text" style=font-size:15px;>
        输入激活码点击立即开通即充值成功，成为会员。
      </div>
      <div id="weichat" class="open-vip-b-kefu">


      </div>
    </div>
  </div>

</body>
<script type="text/javascript" src="../script/api.js" ></script>
<script type="text/javascript">
    var user_id = localStorage.getItem('user_id');
    var api_url = localStorage.getItem('api_url');
    apiready = function(){
      api.parseTapmode();
      newLoingdata();

      var clipBoard = api.require('clipBoard');
      clipBoard.get(function(ret, err) {
          if (ret) {

            if (ret.value.length == 15) {
              var kami = $api.byId('kami');
              kami.value = ret.value;
              api.toast({
                  msg: '已帮您自动粘贴刚刚复制的内容',
                  duration: 4000,
                  location: 'middle'
              });
            }
          } else {

          }
      });


    }

    function newLoingdata(){
      api.ajax({
          url: api_url+'/login/login/veifys.html',
          method: 'get',
          data: {
              values: {
                  username: localStorage.getItem('user_name'),
                  passwd: localStorage.getItem('password'),
                  imei:api.deviceId
              }
          }
      },function(ret, err){
          if (ret) {
            if (ret.code == 0) {
              alert('出错了，请尝试重新登录');
              return;
            }else if (ret.code == 1) {
                localStorage.setItem('user_id',ret.msg['id']);
                localStorage.setItem('user_time',ret.msg['time']);
                localStorage.setItem('user_share',ret.msg['share']);
                localStorage.setItem('user_advert',ret.msg['advert']);
                localStorage.setItem('user_code',ret.msg['code']);
                localStorage.setItem('user_weichat',ret.msg['weichat']);
                localStorage.setItem('url',ret.msg['url']);
                localStorage.setItem('url1',ret.msg['url1']);
                localStorage.setItem('url2',ret.msg['url2']);
                localStorage.setItem('url3',ret.msg['url3']);
                localStorage.setItem('url4',ret.msg['url4']);
                var weichatdiv = $api.byId('weichat');
                weichatdiv.innerHTML = localStorage.getItem('url')+'<br>'+localStorage.getItem('user_weichat');
                api.sendEvent({
                  name: 'newLoingdata',
                  extra: {
                  }
                });
            }
          } else {
            alert('网络错误！');
            return;
          }
      });
    }


    function openUrl1(){

      if (localStorage.getItem('url1') == '无数据') {
        keFu();
        return;
      }else if (localStorage.getItem('url1') == '') {
        keFu();
        return;
      }else {
        toBanner(localStorage.getItem('url1'));
      }
    }
    function openUrl2(){
      if (localStorage.getItem('url2') == '无数据') {
        keFu();
        return;
      }else if (localStorage.getItem('url2') == '') {
        keFu();
        return;
      }else {
        toBanner(localStorage.getItem('url2'));
      }
    }
    function openUrl3(){
      if (localStorage.getItem('url3') == '无数据') {
        keFu();
        return;
      }else if (localStorage.getItem('url3') == '') {
        keFu();
        return;
      }else {
        toBanner(localStorage.getItem('url3'));
      }
    }
    function openUrl4(){
      if (localStorage.getItem('url4') == '无数据') {
        keFu();
        return;
      }else if (localStorage.getItem('url14') == '') {
        keFu();
        return;
      }else {
        toBanner(localStorage.getItem('url4'));
      }
    }

    //访问地址
    function toBanner(url){
      var sys = api.systemType;
      if (sys == 'ios') {
        if (url == '') {
          keFu();
          return;
        }else {
          api.openApp({
                 iosUrl: url
         },function(ret,err){
         });
        }
      }else {
        // if (url == '') {
        //
        // }else {
        //   api.openApp({
        //       androidPkg: 'android.intent.action.VIEW',
        //       mimeType: 'text/html',
        //       uri: url
        //   }, function(ret, err) {
        //       // if (ret) {
        //       //     alert(JSON.stringify(ret));
        //       // } else {
        //       //     alert(JSON.stringify(err));
        //       // }
        //   });
        //
        // }
        if (url == '') {
          keFu();
          return;
        }else {
          api.openWin({
              name: 'h5',
              url: './h5.html',
              pageParam: {
                  url: url
              }
          });
        }

      }

      // if (url == '') {
      //
      // }else {
      //   api.openWin({
      //       name: 'h5',
      //       url: './h5.html',
      //       pageParam: {
      //           url: url
      //       }
      //   });
      // }
    }

    function keFu(){
      var dialogBox = api.require('dialogBox');
      dialogBox.alert({
          texts: {
              content: localStorage.getItem('url')+localStorage.getItem('user_weichat'),
              leftBtnTitle: '知道了',
              rightBtnTitle: '复制'
          },
          styles: {
              bg: '#fff',
              w: 300,
              content: {
                  color: '#000',
                  size: 16
              },
              left: {
                  marginB: 7,
                  marginL: 20,
                  w: 130,
                  h: 35,
                  corner: 2,
                  bg: '#ff7600',
                  color: '#fff',
                  size: 14
              },
              right: {
                  marginB: 7,
                  marginL: 10,
                  w: 130,
                  h: 35,
                  corner: 2,
                  bg: '#ff7600',
                  color: '#fff',
                  size: 14
              }
          }
      }, function(ret) {
          if (ret.eventType == 'left') {
              var dialogBox = api.require('dialogBox');
              dialogBox.close({
                  dialogName: 'alert'
              });
          }else if (ret.eventType == 'right') {
            var clipBoard = api.require('clipBoard');
            clipBoard.set({
                value: localStorage.getItem('user_weichat')
            }, function(ret, err) {
                if (ret) {
                  api.toast({
                      msg: '已复制号码到剪切板',
                      duration: 2000
                  });
                  var dialogBox = api.require('dialogBox');
                  dialogBox.close({
                      dialogName: 'alert'
                  });
                } else {

                }
            });
          }
      });
    }


    //充值点卡
    function loginOff(){
      var kami = $api.val($api.byId('kami'));
      if(kami == ''){
        api.alert({
            title: '调皮~',
            msg: '请输入卡密',
        });
        return;
      }
      if (user_id<1) {
        alert('请先登录');
        api.openWin({
            name: 'login',
            url: './login.html',
        });
        return;
      }else {
        api.showProgress({
            title: '登陆中...',
            text: '请骚等...',
            modal: false
        });
        api.ajax({
            url: api_url+'/login/login/dianka.html',
            method: 'get',
            data: {
                values: {
                    uid: localStorage.getItem('user_id'),
                    dianka: kami,
                }
            }
        },function(ret, err){
            if (ret) {
                if (ret.code == 0) {
                  api.hideProgress();
                  api.alert({
                      title: '哎哟~',
                      msg: ret.msg,
                  });
                  return;
                }else if (ret.code == 1) {
                  api.hideProgress();
                  api.alert({
                      title: '恭喜!',
                      msg: '充值成功',
                  });
                  localStorage.setItem('user_time',ret.lasttime);
                  api.sendEvent({
                    name: 'newLoingdata',
                    extra: {
                    }
                  });
                  api.closeWin();

                }

            } else {
              api.hideProgress();
              api.alert({
                  title: '糟糕~',
                  msg: '网络似乎有点问题',
              });
            }
        });

      }
    }


</script>
</html>
